<?php defined('SYSPATH') or die('No direct script access.');

class Controller_User_Account extends Controller_DefaultTemplate{

public function action_index()
{
	$this->template->content = View::factory('user/account');
}

public function action_update()
{
	if ($_POST)
	{
		$auth = Auth::instance();
		$password = arr::get($_POST, 'currentPassword');
		if ( $auth->check_password($password) )
		{
			$password_new = arr::get($_POST, 'newPassword');
			$auth->get_user()->password = $password_new;
			$auth->get_user()->save();
		}
	}
}

/**
* Initialize properties before running the controller methods (actions),
* so they are available to our action.
*/
public function before()
{
	// Run anything that need ot run before this.
	parent::before();

	if (!Auth::instance()->logged_in())
	{
		$this->request->redirect('/user/login');
	}
}

}




